<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.util.Constants,com.hs.core.utils.*" pageEncoding="UTF-8"%>
<%@ page import ="cn.ac.cintcm.dataconverge.researchsubject.domain.*,cn.ac.cintcm.dataconverge.researcher.domain.*" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Subject obj = (Subject)request.getAttribute("obj");
Long  subjectId = (Long)request.getAttribute("subjectId");
String imagePath = path + "/index/";
Map fileType = (Map)request.getAttribute("fileType");
List fileTypeList = (List)request.getAttribute("fileTypeList");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title><%=Constants.APP_TITLE %></title>  
	<script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
	<script language="javascript" src="<%=path %>/index/Scripts/script.js"></script>
	<script language="javascript" src="<%=path %>/js/common.js"></script>
	<link href="<%=path %>/index/Themes/com/style.css" type="text/css" rel="stylesheet"></link>
	<script src='<%=basePath%>dwr/engine.js'></script>
     <script src='<%=basePath%>dwr/util.js'></script> 
     <script src='<%=basePath%>dwr/interface/subject.js'></script>   
    <script type="text/javascript">
   	    function uploadFile(){
	             
	            if(isNull(form1.taskname.value)){
	            	alert("请填写任务名称");
	            	return;
	            }
	             if(isNull(form1.taskunit.value)){
	            	alert("请填写任务承担单位");
	            	return;
	            } 
	            if(isNull(form1.tasktarget.value)){
	            	alert("请填写目标");
	            	return;
	            }
	             if(isNull(form1.searchcontent.value)){
	            	alert("请填写研究内容");
	            	return;
	            } 
	             if(isNull(form1.taskgoal.value)){
	            	alert("请填写考核指标");
	            	return;
	            }
	             if(isNull(form1.taskdate.value)){
	            	alert("请填写任务时间节点");
	            	return;
	            }
	            if(isNull(form1.taskuser.value)){
	            	alert("请填写任务负责人");
	            	return;
	            }
	             if(isNull(form1.contrymoney.value)){
	            	alert("请填写国拨经费");
	            	return;
	            }
	    		form1.submit();
	    } 
    
    		function addrow(obj){
			 if(obj.delid==0){
				    obj.value="删除";
				    obj.title="删除";
				    obj.delid="1";
				    
					var newTr = dataTable.insertRow(obj.parentElement.parentElement.rowIndex+1);
					var newTd1 = newTr.insertCell();
					var newTd2 = newTr.insertCell();
					newTd1.align="right";
					newTd1.className= "fim_l";			
					newTd1.innerText = ' 选择文件     '; 	
					newTd2.className= "fim_r";	
					newTd2.innerHTML= "&nbsp;<input type='file' style='width:50%' name='textfield2' class='com_textbox' onpaste='return false;' onkeydown='this.blur();return false;' oncontextmenu='return false;'/>&nbsp;<INPUT type='button' value=' 增加 ' title='添加'  delid='0' onclick='addrow(this);' class='com_btn2'>";
			   }else{
			    del(obj);
			   }
		 }
 function del(obj){
	 //parentElement.parentElement.rowIndex
	 if(obj.parentElement.parentElement.rowIndex!=undefined)
	 {
	 	document.getElementById("dataTable").deleteRow(obj.parentElement.parentElement.rowIndex);
	 }
  }
  	function deleteDoc(docId,location) {
		var bln = window.confirm("确定要删除文档嘛？", "确定", "取消");
		if(bln == true) {
		   subject.delSubjectDoc(docId,location,CallBackForDelete);
		}
	}
	function CallBackForDelete(data){
	   alert(data);
	   window.location.replace(window.location.href);
	}
	
	function deleteDoc(docId,location) {
		var bln = window.confirm("确定要删除任务吗？", "确定", "取消");
		if(bln == true) {
		  form1.action="fund.htm?action=delTask&fundId="+docId+"&subjectId=<%=obj==null?"":obj.getId()%>";
		  form1.submit();
		}
	}
    </script>
</head>
<body class="rtm_body"> 
         <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <div class="content">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4">
                        <tr>
                            <td class="dg_headerstyle" width="5%">
                               	序号</td>
                            <td class="dg_headerstyle"  >
                             	任务名称</td>
                            <td class="dg_headerstyle" >
                                 承担单位</td>
                            <td class="dg_headerstyle">
                                目标</td> 
                            <td class="dg_headerstyle">
                                研究内容</td>
                                 <td class="dg_headerstyle">
                                考核指标</td>
                              <td class="dg_headerstyle">
                                任务时间点</td>
                              <td class="dg_headerstyle">
                                任务负责人</td>
                               <td class="dg_headerstyle">
                                国拨经费</td>
                            <td class="dg_headerstyle">
                                删除</td> 
                        </tr>
                        <%if(obj!= null && obj.getTasks() != null &&obj.getTasks().size()!=0){
                        		Set set = obj.getTasks();
                        		Iterator it = set.iterator();
                        		int i = 0;
                        		while(it.hasNext()){
                        			ResmanTaskassign doc = (ResmanTaskassign)it.next();
                        			i++; 
                         %>
                        <tr class="dg_alternatingitemstyle">
                            <td align="center"><%=i %></td>
                            <td>
                                <%=doc.getTaskname() %>   
                            </td>
                            <td align="center" width="20%">
                                <%=doc.getTaskunit() %>
                            </td>
                            <td align="center">
                                <%=doc.getTarget() %>
                            </td>
                            <td align="center">
                                 <%=doc.getTargetcontent() %>
                            </td>
                            <td align="center">
                                 <%=doc.getCheckgoal() %>
                            </td>
                            <td align="center">
                                 <%=doc.getTaskdate() %>
                            </td>
                            <td align="center">
                                 <%=doc.getTaskuser() %>
                            </td>
                             <td align="center">
                                 <%=doc.getContrymoney() %>
                            </td>
                            <td align="center">
                                <img src="<%=imagePath %>Themes/com/68design.net_registration1_(delete)_16x16.gif" onclick="javascript:deleteDoc('<%=doc.getId()%>');"
                                    alt="删除" />
                            </td> 
                        </tr> 
                        <%}}else{ %>
                         <tr class="dg_alternatingitemstyle">
                            <td colspan=10 align="center"><font color=red>该项目没有相关任务</font></td>
                        </tr>  
                        <%} %>
                    </table>  
                </div>
            </td>
        </tr>
    </table> 
    <form name="form1" action="fund.htm?action=addTask" method="post" >
    <table cellpadding="0" cellspacing="0" width="100%"  height="100%" id="Table8">
        <tr valign="top">
            <td valign="top" height="100%">
                <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="Table11">
                    <tr>
                        <td class="idt_main_m">
                            <!------------------ 标题栏 ------------------>
                            <!--- 标题 ---->
                            <table class="idt_tle_mg" cellspacing="0" cellpadding="0" width="100%">
                                <tr  >
                                    <td class="idt_tle_i">
                                        <img id="imgForm6" src="<%=imagePath %>Themes/com/idt_tle_o.gif"></td>
                                    <td class="idt_tle_f1">
                                        添加任务分管</td>
                                </tr>
                            </table>
                            <!--- 内容 --->
                            <div id="tdForm">
                                <table border="0" cellpadding="0" id="dataTable" cellspacing="1" width="100%" class="com_fieldset_tab">
                                    <tr>
                                        <td class="fim_l" width="15%">
                                            任务名称
                                        </td> 
                                        <td class="fim_r" width="35%">
                                          <input type="hidden" name="subjectid" value="<%=obj==null?"":obj.getId() %>"/>
                                        
                                             <input type="text" class="com_textbox" style="width:100%"  name="taskname" />
                                        </td>
                                        <td class="fim_l" width="15%">
                                           承担单位
                                        </td> 
                                        <td class="fim_r" width="35%">
                                             <input type="text" class="com_textbox" style="width:100%"  name="taskunit" />
                                        </td>
                                    </tr>
                                    <tr>
		                                            <td class="fim_l" width="10%">目标</td>
		                                            <td   colspan=3 width="100%">
		                                            	<textarea rows="3"  class="com_textarea" cols=""   style="background-color: #F9F2E6;"  name="tasktarget" style="width:100%;" ></textarea>
		                                            </td>  
		                                        </tr> 
                                   <tr>
                                            <td class="fim_l" width="10%">研究内容</td>
                                            <td   colspan=3 width="100%">
                                            	<textarea rows="3"  class="com_textarea" cols=""   style="background-color: #F9F2E6;"  name="searchcontent" style="width:100%;" ></textarea>
                                            </td>  
                                        </tr> 
                                    <tr>
                                        <td class="fim_l" width="15%">
                                            考核指标
                                        </td> 
                                        <td class="fim_r" width="35%">
                                             <input type="text" class="com_textbox" style="width:100%"  name="taskgoal" />
                                        </td>
                                        <td class="fim_l" width="15%">
                                           任务时间点
                                        </td> 
                                        <td class="fim_r" width="35%">
                                             <input type="text" class="com_textbox" style="width:100%"  name="taskdate" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="fim_l" width="15%">
                                            任务负责人
                                        </td> 
                                        <td class="fim_r" width="35%">
                                             <input type="text" class="com_textbox" style="width:100%"  name="taskuser" />
                                        </td>
                                        <td class="fim_l" width="15%">
                                           国拨经费
                                        </td> 
                                        <td class="fim_r" width="35%">
                                             <input type="text" class="com_textbox" style="width:100%"  name="contrymoney" />
                                        </td>
                                    </tr>
                                     
                                    <tr> 
                                        <td class="fim_r" colspan="4" style="width:100%" align="center">
                                           <input type="button" value=" 保 存 "  class="com_btn2"   onclick="javascript:uploadFile();"/>
                                        </td>                           
                                    </tr> 
                                </table> 
                                 
                            </div>
                </table> 
       </td>
       </tr>
       </table>
        
       </form>
</body>
</html>
